<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            position: absolute;
            top: 100px;
            left: 100px;
            width: 200px;
            height: 200px;
            background-color: #f00;
        }
    </style>
</head>
<body>
    <div></div>

    <script>
        var div=document.querySelector('div');
        // alert(div.offsetTop);
        // alert(div.offsetLeft);

        div.onclick=function(e){
            // alert(e.pageX);
            // alert(e.pageY);
            var x=e.pageX-div.offsetLeft;
            var y=e.pageY-div.offsetTop;
            alert(x);
            alert(y);
        }
    </script>
</body>
</html>